<?php


/**
 * Base class that represents a query for the 'view_bonus_report' table.
 *
 *
 *
 * @method EmpevalViewBonusReportQuery orderByBonusGoalsFormId($order = Criteria::ASC) Order by the bonus_goals_form_id column
 * @method EmpevalViewBonusReportQuery orderByFname($order = Criteria::ASC) Order by the fname column
 * @method EmpevalViewBonusReportQuery orderByLname($order = Criteria::ASC) Order by the lname column
 * @method EmpevalViewBonusReportQuery orderByDepartment($order = Criteria::ASC) Order by the department column
 * @method EmpevalViewBonusReportQuery orderByIndividualValue($order = Criteria::ASC) Order by the individual_value column
 * @method EmpevalViewBonusReportQuery orderByCorporatedValue($order = Criteria::ASC) Order by the corporated_value column
 * @method EmpevalViewBonusReportQuery orderByYear($order = Criteria::ASC) Order by the year column
 * @method EmpevalViewBonusReportQuery orderByPeriod($order = Criteria::ASC) Order by the period column
 * @method EmpevalViewBonusReportQuery orderByPeriodFrom($order = Criteria::ASC) Order by the period_from column
 * @method EmpevalViewBonusReportQuery orderByPeriodTo($order = Criteria::ASC) Order by the period_to column
 *
 * @method EmpevalViewBonusReportQuery groupByBonusGoalsFormId() Group by the bonus_goals_form_id column
 * @method EmpevalViewBonusReportQuery groupByFname() Group by the fname column
 * @method EmpevalViewBonusReportQuery groupByLname() Group by the lname column
 * @method EmpevalViewBonusReportQuery groupByDepartment() Group by the department column
 * @method EmpevalViewBonusReportQuery groupByIndividualValue() Group by the individual_value column
 * @method EmpevalViewBonusReportQuery groupByCorporatedValue() Group by the corporated_value column
 * @method EmpevalViewBonusReportQuery groupByYear() Group by the year column
 * @method EmpevalViewBonusReportQuery groupByPeriod() Group by the period column
 * @method EmpevalViewBonusReportQuery groupByPeriodFrom() Group by the period_from column
 * @method EmpevalViewBonusReportQuery groupByPeriodTo() Group by the period_to column
 *
 * @method EmpevalViewBonusReportQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method EmpevalViewBonusReportQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method EmpevalViewBonusReportQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method EmpevalViewBonusReportQuery leftJoinTaskGoals($relationAlias = null) Adds a LEFT JOIN clause to the query using the TaskGoals relation
 * @method EmpevalViewBonusReportQuery rightJoinTaskGoals($relationAlias = null) Adds a RIGHT JOIN clause to the query using the TaskGoals relation
 * @method EmpevalViewBonusReportQuery innerJoinTaskGoals($relationAlias = null) Adds a INNER JOIN clause to the query using the TaskGoals relation
 *
 * @method EmpevalViewBonusReportQuery leftJoinKpi($relationAlias = null) Adds a LEFT JOIN clause to the query using the Kpi relation
 * @method EmpevalViewBonusReportQuery rightJoinKpi($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Kpi relation
 * @method EmpevalViewBonusReportQuery innerJoinKpi($relationAlias = null) Adds a INNER JOIN clause to the query using the Kpi relation
 *
 * @method EmpevalViewBonusReport findOne(PropelPDO $con = null) Return the first EmpevalViewBonusReport matching the query
 * @method EmpevalViewBonusReport findOneOrCreate(PropelPDO $con = null) Return the first EmpevalViewBonusReport matching the query, or a new EmpevalViewBonusReport object populated from the query conditions when no match is found
 *
 * @method EmpevalViewBonusReport findOneByBonusGoalsFormId(int $bonus_goals_form_id) Return the first EmpevalViewBonusReport filtered by the bonus_goals_form_id column
 * @method EmpevalViewBonusReport findOneByFname(string $fname) Return the first EmpevalViewBonusReport filtered by the fname column
 * @method EmpevalViewBonusReport findOneByLname(string $lname) Return the first EmpevalViewBonusReport filtered by the lname column
 * @method EmpevalViewBonusReport findOneByDepartment(string $department) Return the first EmpevalViewBonusReport filtered by the department column
 * @method EmpevalViewBonusReport findOneByIndividualValue(string $individual_value) Return the first EmpevalViewBonusReport filtered by the individual_value column
 * @method EmpevalViewBonusReport findOneByCorporatedValue(string $corporated_value) Return the first EmpevalViewBonusReport filtered by the corporated_value column
 * @method EmpevalViewBonusReport findOneByYear(int $year) Return the first EmpevalViewBonusReport filtered by the year column
 * @method EmpevalViewBonusReport findOneByPeriod(string $period) Return the first EmpevalViewBonusReport filtered by the period column
 * @method EmpevalViewBonusReport findOneByPeriodFrom(string $period_from) Return the first EmpevalViewBonusReport filtered by the period_from column
 * @method EmpevalViewBonusReport findOneByPeriodTo(string $period_to) Return the first EmpevalViewBonusReport filtered by the period_to column
 *
 * @method array findByBonusGoalsFormId(int $bonus_goals_form_id) Return EmpevalViewBonusReport objects filtered by the bonus_goals_form_id column
 * @method array findByFname(string $fname) Return EmpevalViewBonusReport objects filtered by the fname column
 * @method array findByLname(string $lname) Return EmpevalViewBonusReport objects filtered by the lname column
 * @method array findByDepartment(string $department) Return EmpevalViewBonusReport objects filtered by the department column
 * @method array findByIndividualValue(string $individual_value) Return EmpevalViewBonusReport objects filtered by the individual_value column
 * @method array findByCorporatedValue(string $corporated_value) Return EmpevalViewBonusReport objects filtered by the corporated_value column
 * @method array findByYear(int $year) Return EmpevalViewBonusReport objects filtered by the year column
 * @method array findByPeriod(string $period) Return EmpevalViewBonusReport objects filtered by the period column
 * @method array findByPeriodFrom(string $period_from) Return EmpevalViewBonusReport objects filtered by the period_from column
 * @method array findByPeriodTo(string $period_to) Return EmpevalViewBonusReport objects filtered by the period_to column
 *
 * @package    propel.generator.empeval.om
 */
abstract class EmpevalBaseViewBonusReportQuery extends ModelCriteria
{
    /**
     * Initializes internal state of EmpevalBaseViewBonusReportQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_empeval', $modelName = 'EmpevalViewBonusReport', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new EmpevalViewBonusReportQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     EmpevalViewBonusReportQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return EmpevalViewBonusReportQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof EmpevalViewBonusReportQuery) {
            return $criteria;
        }
        $query = new EmpevalViewBonusReportQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   EmpevalViewBonusReport|EmpevalViewBonusReport[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = EmpevalViewBonusReportPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(EmpevalViewBonusReportPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   EmpevalViewBonusReport A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT BONUS_GOALS_FORM_ID, FNAME, LNAME, DEPARTMENT, INDIVIDUAL_VALUE, CORPORATED_VALUE, YEAR, PERIOD, PERIOD_FROM, PERIOD_TO FROM view_bonus_report WHERE BONUS_GOALS_FORM_ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new EmpevalViewBonusReport();
            $obj->hydrate($row);
            EmpevalViewBonusReportPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return EmpevalViewBonusReport|EmpevalViewBonusReport[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|EmpevalViewBonusReport[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::BONUS_GOALS_FORM_ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::BONUS_GOALS_FORM_ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the bonus_goals_form_id column
     *
     * Example usage:
     * <code>
     * $query->filterByBonusGoalsFormId(1234); // WHERE bonus_goals_form_id = 1234
     * $query->filterByBonusGoalsFormId(array(12, 34)); // WHERE bonus_goals_form_id IN (12, 34)
     * $query->filterByBonusGoalsFormId(array('min' => 12)); // WHERE bonus_goals_form_id > 12
     * </code>
     *
     * @param     mixed $bonusGoalsFormId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByBonusGoalsFormId($bonusGoalsFormId = null, $comparison = null)
    {
        if (is_array($bonusGoalsFormId) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::BONUS_GOALS_FORM_ID, $bonusGoalsFormId, $comparison);
    }

    /**
     * Filter the query on the fname column
     *
     * Example usage:
     * <code>
     * $query->filterByFname('fooValue');   // WHERE fname = 'fooValue'
     * $query->filterByFname('%fooValue%'); // WHERE fname LIKE '%fooValue%'
     * </code>
     *
     * @param     string $fname The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByFname($fname = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($fname)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $fname)) {
                $fname = str_replace('*', '%', $fname);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::FNAME, $fname, $comparison);
    }

    /**
     * Filter the query on the lname column
     *
     * Example usage:
     * <code>
     * $query->filterByLname('fooValue');   // WHERE lname = 'fooValue'
     * $query->filterByLname('%fooValue%'); // WHERE lname LIKE '%fooValue%'
     * </code>
     *
     * @param     string $lname The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByLname($lname = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($lname)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $lname)) {
                $lname = str_replace('*', '%', $lname);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::LNAME, $lname, $comparison);
    }

    /**
     * Filter the query on the department column
     *
     * Example usage:
     * <code>
     * $query->filterByDepartment('fooValue');   // WHERE department = 'fooValue'
     * $query->filterByDepartment('%fooValue%'); // WHERE department LIKE '%fooValue%'
     * </code>
     *
     * @param     string $department The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByDepartment($department = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($department)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $department)) {
                $department = str_replace('*', '%', $department);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::DEPARTMENT, $department, $comparison);
    }

    /**
     * Filter the query on the individual_value column
     *
     * Example usage:
     * <code>
     * $query->filterByIndividualValue(1234); // WHERE individual_value = 1234
     * $query->filterByIndividualValue(array(12, 34)); // WHERE individual_value IN (12, 34)
     * $query->filterByIndividualValue(array('min' => 12)); // WHERE individual_value > 12
     * </code>
     *
     * @param     mixed $individualValue The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByIndividualValue($individualValue = null, $comparison = null)
    {
        if (is_array($individualValue)) {
            $useMinMax = false;
            if (isset($individualValue['min'])) {
                $this->addUsingAlias(EmpevalViewBonusReportPeer::INDIVIDUAL_VALUE, $individualValue['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($individualValue['max'])) {
                $this->addUsingAlias(EmpevalViewBonusReportPeer::INDIVIDUAL_VALUE, $individualValue['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::INDIVIDUAL_VALUE, $individualValue, $comparison);
    }

    /**
     * Filter the query on the corporated_value column
     *
     * Example usage:
     * <code>
     * $query->filterByCorporatedValue(1234); // WHERE corporated_value = 1234
     * $query->filterByCorporatedValue(array(12, 34)); // WHERE corporated_value IN (12, 34)
     * $query->filterByCorporatedValue(array('min' => 12)); // WHERE corporated_value > 12
     * </code>
     *
     * @param     mixed $corporatedValue The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByCorporatedValue($corporatedValue = null, $comparison = null)
    {
        if (is_array($corporatedValue)) {
            $useMinMax = false;
            if (isset($corporatedValue['min'])) {
                $this->addUsingAlias(EmpevalViewBonusReportPeer::CORPORATED_VALUE, $corporatedValue['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($corporatedValue['max'])) {
                $this->addUsingAlias(EmpevalViewBonusReportPeer::CORPORATED_VALUE, $corporatedValue['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::CORPORATED_VALUE, $corporatedValue, $comparison);
    }

    /**
     * Filter the query on the year column
     *
     * Example usage:
     * <code>
     * $query->filterByYear(1234); // WHERE year = 1234
     * $query->filterByYear(array(12, 34)); // WHERE year IN (12, 34)
     * $query->filterByYear(array('min' => 12)); // WHERE year > 12
     * </code>
     *
     * @param     mixed $year The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByYear($year = null, $comparison = null)
    {
        if (is_array($year)) {
            $useMinMax = false;
            if (isset($year['min'])) {
                $this->addUsingAlias(EmpevalViewBonusReportPeer::YEAR, $year['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($year['max'])) {
                $this->addUsingAlias(EmpevalViewBonusReportPeer::YEAR, $year['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::YEAR, $year, $comparison);
    }

    /**
     * Filter the query on the period column
     *
     * Example usage:
     * <code>
     * $query->filterByPeriod('fooValue');   // WHERE period = 'fooValue'
     * $query->filterByPeriod('%fooValue%'); // WHERE period LIKE '%fooValue%'
     * </code>
     *
     * @param     string $period The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByPeriod($period = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($period)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $period)) {
                $period = str_replace('*', '%', $period);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::PERIOD, $period, $comparison);
    }

    /**
     * Filter the query on the period_from column
     *
     * Example usage:
     * <code>
     * $query->filterByPeriodFrom('fooValue');   // WHERE period_from = 'fooValue'
     * $query->filterByPeriodFrom('%fooValue%'); // WHERE period_from LIKE '%fooValue%'
     * </code>
     *
     * @param     string $periodFrom The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByPeriodFrom($periodFrom = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($periodFrom)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $periodFrom)) {
                $periodFrom = str_replace('*', '%', $periodFrom);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::PERIOD_FROM, $periodFrom, $comparison);
    }

    /**
     * Filter the query on the period_to column
     *
     * Example usage:
     * <code>
     * $query->filterByPeriodTo('fooValue');   // WHERE period_to = 'fooValue'
     * $query->filterByPeriodTo('%fooValue%'); // WHERE period_to LIKE '%fooValue%'
     * </code>
     *
     * @param     string $periodTo The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function filterByPeriodTo($periodTo = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($periodTo)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $periodTo)) {
                $periodTo = str_replace('*', '%', $periodTo);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(EmpevalViewBonusReportPeer::PERIOD_TO, $periodTo, $comparison);
    }

    /**
     * Filter the query by a related EmpevalTaskGoals object
     *
     * @param   EmpevalTaskGoals|PropelObjectCollection $taskGoals  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalViewBonusReportQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByTaskGoals($taskGoals, $comparison = null)
    {
        if ($taskGoals instanceof EmpevalTaskGoals) {
            return $this
                ->addUsingAlias(EmpevalViewBonusReportPeer::BONUS_GOALS_FORM_ID, $taskGoals->getBonusGoalsFormId(), $comparison);
        } elseif ($taskGoals instanceof PropelObjectCollection) {
            return $this
                ->useTaskGoalsQuery()
                ->filterByPrimaryKeys($taskGoals->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByTaskGoals() only accepts arguments of type EmpevalTaskGoals or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the TaskGoals relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function joinTaskGoals($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('TaskGoals');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'TaskGoals');
        }

        return $this;
    }

    /**
     * Use the TaskGoals relation TaskGoals object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalTaskGoalsQuery A secondary query class using the current class as primary query
     */
    public function useTaskGoalsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinTaskGoals($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'TaskGoals', 'EmpevalTaskGoalsQuery');
    }

    /**
     * Filter the query by a related EmpevalKpi object
     *
     * @param   EmpevalKpi|PropelObjectCollection $kpi  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalViewBonusReportQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByKpi($kpi, $comparison = null)
    {
        if ($kpi instanceof EmpevalKpi) {
            return $this
                ->addUsingAlias(EmpevalViewBonusReportPeer::BONUS_GOALS_FORM_ID, $kpi->getBonusGoalsFormId(), $comparison);
        } elseif ($kpi instanceof PropelObjectCollection) {
            return $this
                ->useKpiQuery()
                ->filterByPrimaryKeys($kpi->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByKpi() only accepts arguments of type EmpevalKpi or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Kpi relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function joinKpi($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Kpi');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Kpi');
        }

        return $this;
    }

    /**
     * Use the Kpi relation Kpi object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalKpiQuery A secondary query class using the current class as primary query
     */
    public function useKpiQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinKpi($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Kpi', 'EmpevalKpiQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   EmpevalViewBonusReport $viewBonusReport Object to remove from the list of results
     *
     * @return EmpevalViewBonusReportQuery The current query, for fluid interface
     */
    public function prune($viewBonusReport = null)
    {
        if ($viewBonusReport) {
            $this->addUsingAlias(EmpevalViewBonusReportPeer::BONUS_GOALS_FORM_ID, $viewBonusReport->getBonusGoalsFormId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
